package lib;

public abstract class Tri {
	private int[] t;
	private boolean modDebug=false;
	
	public Tri(int nb)
	{
		this.setT(new int[nb]);
		this.valeurAleatoires(nb);
	}

	public int[] getT() {
		return t;
	}
	
	public int getElement(int i) {
	
		return this.getT()[i];
	}
	
	public void setElement(int i,int valeur) {
		
		 this.getT()[i]=valeur;
	}
	
	public void setT(int[] t) {
		this.t = t;
	}
		
	public abstract void tri();
	
	protected void permuter(int a, int b)
	{
		int tmp = this.getElement(a);
		this.setElement(a, this.getElement(b));
		this.setElement(b, tmp);
	}
	
	protected void valeurAleatoires(int nb)
	{
		while(nb>0)
		{
			this.setElement(nb-1,(int)(Math.random()*nb));
			--nb;
		}
	}

	/**
	 * @return the modDebug
	 */
	public boolean isModDebug() {
		return modDebug;
	}

	/**
	 * @param modDebug the modDebug to set
	 */
	public void setModDebug(boolean modDebug) {
		this.modDebug = modDebug;
	}
	
	public void afficheTableau()
	{
		for(int i : this.getT())
		{
			System.out.println(i);
		}
	}

}
